package com.zqh.irmadscore.controller;


import com.zqh.irmadscore.model.dto.PredictionRequest;
import com.zqh.irmadscore.model.entity.PredictData;
import com.zqh.irmadscore.service.PredictService;
import com.zqh.irmadscore.utils.resultUtils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequiredArgsConstructor
//@RequestMapping("/predicts")
@Tag(name = "模型预测")
public class predictController {


    private final PredictService lstmService;


    @PostMapping("/predict")
    public Result<List<Double>> predict(@RequestBody PredictionRequest request)
            throws IOException, InterruptedException {

        System.out.println("Received values: " + request.getValues());
        List<Double> values = request.getValues();

        lstmService.predict(values);
        return Result.ok();
    }


//    private final String PYTHON_API_URL = "http://127.0.0.1:5001/process";
//
//    @PostMapping("/process")
//    public ResponseEntity<String> processData(@RequestBody Map<String, Object> requestData) {
//        RestTemplate restTemplate = new RestTemplate();
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON);
//
//        HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(requestData, headers);
//        ResponseEntity<String> response = restTemplate.exchange(PYTHON_API_URL, HttpMethod.POST, requestEntity, String.class);
//
//        return response;
//    }


    @GetMapping
    @Operation(summary = "测试")
    public Result<List<PredictData>> getAll() {
//        List<PredictData> list = lstmService.list();
        System.out.println("test");

        return Result.ok();
    }


}
